package org.dtrd.modules.achievement.entity.bean;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.dtrd.common.util.DateUtils;
import org.dtrd.modules.achievement.entity.po.DtrdEntRdSigninPlan;

import java.util.List;

@Data
@ApiModel(value = "打卡计划")
public class SigninPlan extends BaseSigninPlan{

    private Integer doctorId;

    @ApiModelProperty(value = "工作日计划-JSON串")
    private String signInJsonWorkingday;

    @ApiModelProperty(value = "周末计划-JSON串")
    private String signInJsonWeekend;

    @ApiModelProperty(value = "打卡计划-JSON串-周一计划")
    private String signInJsonMonday;

    @ApiModelProperty(value = "打卡计划-JSON串-周二计划")
    private String signInJsonTuesday;

    @ApiModelProperty(value = "打卡计划-JSON串-周三计划")
    private String signInJsonWednesday;

    @ApiModelProperty(value = "打卡计划-JSON串-周四计划")
    private String signInJsonThursday;

    @ApiModelProperty(value = "打卡计划-JSON串-周五计划")
    private String signInJsonFriday;

    @ApiModelProperty(value = "打卡计划-JSON串-周六计划")
    private String signInJsonSaturday;

    @ApiModelProperty(value = "打卡计划-JSON串-周日计划")
    private String signInJsonSunday;

    @ApiModelProperty(value = "打卡计划-数组")
    private List<SignInAction> signInActionList;

    @Override
    public void setSignInJson(String signInJson) {
        super.setSignInJson(signInJson);
        if (signInJson != null) {
            signInActionList = JSONObject.parseArray(signInJson, SignInAction.class);
        }
    }

    public SigninPlan fromPO(DtrdEntRdSigninPlan plan) {
        setDataId(plan.getDataId());
        setPatientId(plan.getPatientId());
        doctorId = plan.getDoctorId();
        setSignInTemplateId(plan.getSignInTemplateId());
        setSignInStatus(plan.getSignInStatus());
        setSignInStartdate(plan.getSignInStartdate());
        setSignInEnddate(plan.getSignInEnddate());
        signInJsonWorkingday = plan.getSignInJsonWorkingday();
        signInJsonWeekend = plan.getSignInJsonWeekend();
        signInJsonMonday = plan.getSignInJsonMonday();
        signInJsonTuesday = plan.getSignInJsonTuesday();
        signInJsonWednesday = plan.getSignInJsonWednesday();
        signInJsonThursday = plan.getSignInJsonThursday();
        signInJsonFriday = plan.getSignInJsonFriday();
        signInJsonSaturday = plan.getSignInJsonSaturday();
        signInJsonSunday = plan.getSignInJsonSunday();
        setSignInJson(plan.getSignInJsonWorkingday());
        return this;
    }

}